<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>

<body>
<!-- view 层 模板-->
<div id="app">
    <p>列表书籍</p>
    <ul>
        <li>Java</li>
        <li>c</li>
        <li>c++</li>
        <li>python</li>
    </ul>

    <todo>
        <!-- v-bind -->
        <todo-title slot="todo-title" :title="title"></todo-title>
        <todo-items slot="todo-items" v-for="item in todoItems " :item="item"></todo-items>
    </todo>



</div>
<!--1.导入vue.js-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js">
    /**
     * 在vue.js 中我们使用<slot〉元素作为承载分发内容的出口，作者称其为插槽，可以应用在组合组件的场景中;
     */
</script>
<script>
    //slot:插槽
    Vue.component("todo", {
        template:
            '<div>' +
            '<slot name="todo-title"></slot>' +
            '<ul>' +
             '<slot name="todo-items"></slot>'+
            '</ul>' +
            '</div>'
    })

    Vue.component("todo-title",{
        props:['title'],
        template: '<div>{{title}}</div>'
    })

    Vue.component("todo-items",{
        props: ['item'],
        template: '<li>{{item}}</li>'
    })

    var vm = new Vue({
        el: "#app",
        data: {
            message: "qinjiang",
            title:"vue 学习列表",
            todoItems:['sandkjbc','家达拉斯快递号','哈哦ID好哦边海防']
        }
    });

</script>
</body>
</html>
